package com.satalyst.webtest.model.page.elements;

import com.satalyst.webtest.model.page.Page;
import com.satalyst.webtest.model.page.PageElement;

import java.util.UUID;

/**
 * A {@see DomElement} represents an element on a {@see Page} that can be interacted with using selenium.
 *
 * @author Aidan Morgan
 */
public class DomElement implements PageElement {
    private UUID id;
    private String name;
    private Page owner;

    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Page getOwner() {
        return owner;
    }

    public void setOwner(Page owner) {
        this.owner = owner;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof DomElement)) return false;

        DomElement that = (DomElement) o;

        return !(id != null ? !id.equals(that.id) : that.id != null);
    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }
}
